package problema047;


public class DistinctPrimesFactors {

	static boolean[] isPrime;
	
	public static void main(String[] args){
		distinct4();
	}
	
	public static void distinct4(){
		sieveOfEratosthenes(10000000);
		double act = 0, busco = 4;
		for(act = 643; ;act++){
			System.out.println(act);
			if(tiene4(act)){busco--;
			}else{busco = 4;}
			if(busco == 0)break;
		}
		System.out.println(act-3);
	}
	
	public static boolean tiene4(double n){
		int cant = 0;
		for(int i = 0; i < n/2; i++){
			if(isPrime[i] && n % i == 0)cant++;
		}
		return cant == 4;
	}
	
	public static void sieveOfEratosthenes(int n){
	     isPrime = new boolean[n + 1];
	     for (int i = 2; i <= n; i++) {
	         isPrime[i] = true;
	     }
	     for (int i = 2; i*i <= n; i++) {
	         if (isPrime[i]) {
	             for (int j = i; i*j <= n; j++) {
	                 isPrime[i*j] = false;
	             }
	         }
	     }
	 }
}
